package controller

import (
	"github.com/crack007/go-im/src/module/api/dto"
	"github.com/crack007/go-im/src/module/api/service"
	"github.com/gin-gonic/gin"
)

type UserController struct {
}

func (c *UserController) Login(ctx *gin.Context) interface{} {
	loginDto := dto.NewLoginDto()
	ctx.ShouldBind(&loginDto)
	return service.UserService.Login(loginDto)
}

func (c *UserController) Register(ctx *gin.Context) interface{} {
	registerDto := dto.NewRegisterDto()
	ctx.ShouldBind(&registerDto)
	return service.UserService.Register(registerDto)
}

func (c *UserController) Search(ctx *gin.Context) interface{} {
	searchUserDto := dto.NewSearchUserDto()
	ctx.ShouldBind(&searchUserDto)
	return service.UserService.Search(searchUserDto)
}

func (c *UserController) AddFriend(ctx *gin.Context) interface{} {
	addFriendDto := dto.NewAddFriendDto()
	ctx.ShouldBind(&addFriendDto)
	return service.UserService.AddFriend(addFriendDto, GetRequestUser(ctx))
}

func (c *UserController) ListFriendApply(ctx *gin.Context) interface{} {
	queryDto := dto.NewQueryDto()
	ctx.ShouldBind(&queryDto)
	return service.UserService.ListAddFriend(GetRequestUser(ctx), queryDto)
}

func (c *UserController) FriendApplyProcess(ctx *gin.Context) interface{} {
	applyDto := dto.NewApplyDto()
	ctx.ShouldBind(&applyDto)
	return service.UserService.FriendApplyProcess(GetRequestUser(ctx), applyDto)
}
